﻿var manager = null;
var url = "../Org/TreeDate";
$(function () {
    InitOrgData();
});
 function InitOrgData() {
     $.get(url, {}, function (orgdata) {
         if (orgdata != undefined) {
             if (manager != null && manager != undefined) { manager.clear(); }
             manager = $(".l-tree").ligerTree({
                 data: [orgdata],
                 checkbox: false,
                 onClick: itemclick
             });
             $("#initLoadingImg").css("display", "none");

         }
     });
 }

 function itemclick(item, i) {
     $("#getnodeid").val(item.data.id);
     $("#getnodename").val(item.data.text);
     $("#getnodeisorg").val(item.data.isorg);
 }

 function ReturnVal() {
     var isOrg = $("#getnodeisorg").val();
     var tipInfo = $("#tipinfo");
     tipInfo.html();
     var selectType = $("#SelectType").val();
     if (selectType == "1") {
         if (isOrg.toString() == "1") {
             window.returnValue = [$("#getnodename").val(), $("#getnodeid").val()];
             window.close();
         } else {
             tipInfo.html("请选择组织机构");
         }
     }
     else if (selectType == "0") {
         if (isOrg.toString() == "0") {
             window.returnValue = [$("#getnodename").val(), $("#getnodeid").val()];
             window.close();
         } else {
             tipInfo.html("请选择部门");
         }
     }
 }

